//
//  UpcomingDisplayItem.m
//  ViperDemo
//
//  Created by Leeesven on 17/5/17.
//  Copyright © 2017年 Leeesven. All rights reserved.
//

#import "UpcomingDisplayItem.h"

@interface UpcomingDisplayItem ()

@property (nonatomic, copy) NSString*   title;
@property (nonatomic, copy) NSString*   dueDay;

@end

@implementation UpcomingDisplayItem

+ (instancetype)upcomingDisplayItemWithTitle:(NSString *)title dueDay:(NSString *)dueDay
{
    UpcomingDisplayItem *item = [[UpcomingDisplayItem alloc] init];
    
    item.title = title;
    item.dueDay = dueDay;
    
    return item;
}


- (NSString *)description
{
    return [NSString stringWithFormat:@"%@    %@ -- %@", [super description], self.title, self.dueDay];
}


- (BOOL)isEqualToUpcomingDisplayItem:(UpcomingDisplayItem *)item
{
    if (!item)
    {
        return NO;
    }
    
    BOOL hasEqualTitles = [self.title isEqualToString:item.title];
    BOOL hasEqualDueDays = [self.dueDay isEqualToString:item.dueDay];
    
    return hasEqualTitles && hasEqualDueDays;
}


- (BOOL)isEqual:(id)object
{
    if (self == object)
    {
        return YES;
    }
    
    if (![object isKindOfClass:[UpcomingDisplayItem class]])
    {
        return NO;
    }
    
    return [self isEqualToUpcomingDisplayItem:object];
}


- (NSUInteger)hash
{
    return [self.title hash] ^ [self.dueDay hash];
}


@end
